
$(document).ready(function ()
{
     dictinoaryName = getQueryString("dictinoaryName");
     dictinoaryValue = getQueryString("dictinoaryValue");

    layui.use('upload', function ()
    {
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        
        $("#dictinoary_type").val(dictinoaryName);
        $("#dictinoary_type").attr("dictinoaryValue",dictinoaryValue);
        
    });

    $("#btn_submit").on("click", function ()
    {
        add();
    });
});


function add() {
    var params = param();
	$.ajax({
		cache : true,
		type : "POST",
		url : ctx+"/system/dictinoary/save",
        data: params,
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
                parent.get_dictinoary_List(params.dictinoaryType);
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg);
			}

		}
	});
}


function param()
{
    return {
        "dictinoaryType": $("#dictinoary_type").attr("dictinoaryValue"),
        "itemvalue": $("#itemvalue").val(),
        "itemname": $("#itemname").val(),
        "orderNum": $("#order_num").val(),
        "description": $("#description").val()
    };
}